package com.hxw.schema.singleton;

/**
 * 常用
 * 饿汉式  --支持多线程 ，类加载时初始化，内存浪费
 * Created by wenx on 2020-02-15 13:34
 */
public class SingletonDemo {

    public static SingletonDemo singletonDemo = new SingletonDemo();

    private SingletonDemo() {
    }

    public static SingletonDemo getInstance() {
        return singletonDemo;
    }

    private void hello() {
        System.out.println("hello singleton!");
    }

    public static void main(String[] args) {
        SingletonDemo instance = SingletonDemo.getInstance();
        instance.hello();
    }

}